# Contributor: Alex Laskin <alex@lask.in>
# Maintainer: Alex Laskin <alex@lask.in>
pkgname=autofs
pkgver=5.1.8
pkgrel=4
pkgdesc="A kernel-based automounter for Linux"
url="https://www.kernel.org/pub/linux/daemons/autofs/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	automake
	bison
	coreutils
	flex
	libnfs-dev
	libtirpc-dev
	linux-headers
	rpcgen
	"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-openrc"
options="!check" # no test suite provided
source="
	https://www.kernel.org/pub/linux/daemons/$pkgname/v5/$pkgname-$pkgver.tar.xz
	autofs.initd
	autofs.confd
	0001-auto.master-change-paths-in-etc.patch
	0002-musl-backport-fixes.patch
	fix-segfault.patch
	"

prepare() {
	default_prepare
	sed -i 's,nfs/nfs.h,linux/nfs.h,g' */*.[ch]
	sed -i 's,__S_IEXEC,S_IXUSR,g' */*.[ch]
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc/autofs \
		--with-mapdir=/etc/autofs \
		--with-confdir=/etc/conf.d \
		--without-hesiod \
		--with-libtirpc \
		--enable-ignore-busy
	make STRIP=:
}

package() {
	make DESTDIR="$pkgdir" install

	mkdir -p "$pkgdir"/etc/autofs/
	install -m644 samples/auto.master \
		samples/auto.misc \
		samples/auto.net \
		samples/auto.smb \
		"$pkgdir"/etc/autofs/

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname

	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname

	rm -f "$pkgdir"/usr/share/man/man5/autofs.5
}

sha512sums="
6ee6283c0977c82848a654dc24745ee687f6916de441c3688fa91f67ca7295e632ee3808cc2358984a4b9f19841e6e1a91ab48aad6341ac8e63827fe8c32d223  autofs-5.1.8.tar.xz
e7ffe40cf5f302f7de7cc59752699adad4be89fa78fa1a79c32ce4059ec2f563c0f107ca2cec850cabfb1cdebca5ff1f369167479423ab6cfe509225a799a00e  autofs.initd
74884b94d8c5dc72579c9c0c9f13c8918ee0babe6fc1e6352bb79cfaf6f5ce3daa87a9b2ea2f34a4600c93a971b329aa0892785fe2efd42829fb7953a6130dd7  autofs.confd
562607fb77347680740a73242390cd199595779acd96033b7b9b4579ef57e8fc887bbcee227964ffeda1710798becd58e957e28c4dd875f2402c9d3989a04aef  0001-auto.master-change-paths-in-etc.patch
e928f89147d29374b1daa97331a2aca858a2ac6de3f91e041806ebbc12ddc861d801921e20d3da3968f154bfbf916456c0cb98ac430b9dd515159436eb135f39  0002-musl-backport-fixes.patch
c705d6cb7be2701bfbbafc01b476e32bc61e26a164002395271dc9bd4175dc6a3d580ad99dbed8d5037ef2fd603aa2530955899258386693905d8e33f7d036c7  fix-segfault.patch
"
